﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public enum TeamType
{
    Left,
    Right
}

public class FightItem
{
    public int Idx;

    public TeamType TeamType;

    public string Name;

    /// <summary>
    /// 渡劫等级
    /// </summary>
    public int DujieLv;

    /// <summary>
    /// 品质
    /// </summary>
    public int PinZhi;

    /// <summary>
    /// 总生命值
    /// </summary>
    public int TotalHp;

    /// <summary>
    /// 剩余hp
    /// </summary>
    public int HP;

    /// <summary>
    /// 能量
    /// </summary>
    public int MP;

    /// <summary>
    /// 攻击
    /// </summary>
    public int ATK;

    /// <summary>
    /// 物理防御
    /// </summary>
    public int DEF;

    /// <summary>
    /// 魔法防御
    /// </summary>
    public int RGS;

    /// <summary>
    /// 命中率
    /// </summary>
    public int DEX;

    /// <summary>
    /// 暴击率
    /// </summary>
    public int CRT;
    /// <summary>
    /// 回避率
    /// </summary>
    public int EVD;
    /// <summary>
    /// 抗暴率
    /// </summary>
    public int KBL;

    /// <summary>
    /// 普通技能Id
    /// </summary>
    public InitSkill NormalSkill;
    /// <summary>
    /// 专属技能Id
    /// </summary>
    public InitSkill ProperSkill;


    public FightItem(Hero hero)
    {
        TotalHp = hero.Attribute.Get(AttributeType.HP);
        ATK = hero.Attribute.Get(AttributeType.ATK);
        DEF = hero.Attribute.Get(AttributeType.DEF);
        RGS = hero.Attribute.Get(AttributeType.RGS);
        DEX = hero.Attribute.Get(AttributeType.DEX);
        CRT = hero.Attribute.Get(AttributeType.CRT);
        EVD = hero.Attribute.Get(AttributeType.EVD);
        KBL = hero.Attribute.Get(AttributeType.KBL);
        HP = TotalHp;
        DujieLv = hero.DuJieLevel;

        InitHero initHero = hero.InitHero;
        if (initHero != null)
        {
            Name = string.Format("{0}·{1}", hero.GetName(), CommonUtil.GetJobName(initHero.job-1));
            PinZhi = initHero.quality;
            if (InitSkillMgr.Dict.TryGetValue(initHero.normal_skill_id, out InitSkill initSkill))
            {
                NormalSkill = initSkill;
            }

            if (InitSkillMgr.Dict.TryGetValue(initHero.proper_skill_id, out InitSkill initSkillPro))
            {
                ProperSkill = initSkillPro;
            }
        }
        else
        {
            Name = string.Format("{0}", hero.GetName());
            PinZhi = 0;
        }
    }

    public FightItem(Monster monster)
    {
        Name = monster.name;
        PinZhi = monster.quality;
        TotalHp = monster.hp;
        ATK = monster.atk;
        DEF = monster.def;
        RGS = monster.rgs;
        DEX = monster.dex;
        CRT = monster.crt;
        EVD = monster.evd;
        KBL = monster.kbl;
        HP = TotalHp;
        DujieLv = 0;

        if (InitSkillMgr.Dict.TryGetValue(monster.normal_skill_id, out InitSkill initSkill))
        {
            NormalSkill = initSkill;
        }

        if (InitSkillMgr.Dict.TryGetValue(monster.proper_skill_id, out InitSkill initSkillPro))
        {
            ProperSkill = initSkillPro;
        }
    }

    public bool isDie()
    {
        return HP <= 0;
    }

    public bool isUseSkill()
    {
        return MP >= 100;
    }
}
